package com.tlxch.controller.teacher;

import com.tlxch.pojo.SEffectWithBLOBs;
import com.tlxch.result.Result;
import com.tlxch.server.teacher.SEffectService;
import com.tlxch.utils.TextSpecialWordChecker;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "学习效果相关接口")
@Slf4j
@RestController
@RequestMapping("/teacher/seffect")
public class SEffectController {
    @Autowired
    SEffectService sEffectService;

    @PostMapping("/add")
    @ApiOperation("添加学习效果")
    public Result addSEffect(@RequestBody SEffectWithBLOBs sEffectWithBLOBs) {
        int i = TextSpecialWordChecker.checkText(sEffectWithBLOBs.getSeAdvice());
        int i1 = TextSpecialWordChecker.checkText(sEffectWithBLOBs.getSeContent());
        if (i == 0 || i1 == 0) {
            return Result.error("含有非法字符");
        }
        sEffectService.addSEffect(sEffectWithBLOBs);
        return Result.success();
    }
}
